package com.kelvin.paopao.utils;


import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;

/**
 * Created by MCK on 2017/5/9.
 */

public class DialogMaker {

    public static Dialog dialog;

    private DialogMaker() {
        throw new RuntimeException("dialogmaker cannot be init by itemself");
    }

    /**
     * 显示进度对话框
     *
     * @param context
     * @param title
     */
    public static void showProgressDialog(Context context, String title) {
        if (dialog == null || !dialog.isShowing()) {
            ProgressDialog progressDialog = new ProgressDialog(context);
            progressDialog.setMessage(title);
            progressDialog.show();

            dialog = progressDialog;
        }
    }

    /**
     * 关闭dialog
     */
    public static void diamiss() {
        if (dialog.isShowing()) {
            dialog.dismiss();
        }
    }
}
